﻿cmake_minimum_required(VERSION 3.16)

project(MeasureView VERSION 2.0.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)

set(TS_FILES MeasureView_zh_CN.ts)

add_library(MeasureView SHARED
  ${TS_FILES}
  DialogMeasure.cpp
  DialogMeasure.h
  DialogMeasure.ui
  ColorComboBox.h
  ImageView.h
  MeasureAlgorithm.h
  MeasureAngle.h
  MeasureArc3P.h
  MeasureCircle2Circle.h
  MeasureCircle2P.h
  MeasureCircle2PSA.h
  MeasureCircle3P.h
  MeasureCircleCenter.h
  MeasureCircleCenterSA.h
  MeasureCount.h
  MeasureDataSet.h
  MeasureDots2Line.h
  MeasureElement.h
  MeasureLine.h
  MeasureLineWidthSA.h
  MeasureLineWidthSA2.h
  MeasureParallelLine.h
  MeasurePolygon.h
  MeasurePolyline.h
  MeasureRect.h
  measureview.h
  TextBlock.h
  ToolBarMeasure.h
  ToolBarProperty.h
  ToolBarSemiAutoMeasure.h
  ToolBarZoom.h
  UnitConvert.h
  src/ImageView.cpp
  src/MeasureAlgorithm.cpp
  src/MeasureAngle.cpp
  src/MeasureArc3P.cpp
  src/MeasureCircle2Circle.cpp
  src/MeasureCircle2P.cpp
  src/MeasureCircle3P.cpp
  src/MeasureCircleCenter.cpp
  src/MeasureCount.cpp
  src/MeasureDataSet.cpp
  src/MeasureDots2Line.cpp
  src/MeasureElement.cpp
  src/MeasureLine.cpp
  src/MeasureParallelLine.cpp
  src/MeasurePolygon.cpp
  src/MeasurePolyline.cpp
  src/MeasureRect.cpp
  src/MeasureView.cpp
  src/TextBlock.cpp
  src/UnitConvert.cpp
  toolbar/ColorComboBox.cpp
  toolbar/ToolBarMeasure.cpp
  toolbar/ToolBarProperty.cpp
  toolbar/ToolBarSemiAutoMeasure.cpp
  toolbar/ToolBarZoom.cpp
  SemiAutoMeasure/DialogSemiAutoMeasure.ui
  SemiAutoMeasure/cagaus.cpp
  SemiAutoMeasure/CircleFitSolver_OpenCV.cpp
  SemiAutoMeasure/DialogSemiAutoMeasure.cpp
  SemiAutoMeasure/DialogSemiAutoMeasure.h
  SemiAutoMeasure/MeasureCircle2PSA.cpp
  SemiAutoMeasure/MeasureCircleCenterSA.cpp
  SemiAutoMeasure/MeasureLineWidthSA.cpp
  SemiAutoMeasure/plinesfit_opencv.cpp
  SemiAutoMeasure/SemiAutoMeasure.cpp
  SemiAutoMeasure/SemiAutoMeasure.h
  #SemiAutoMeasure/MeasureLineWidthSA2.cpp
  res/res.qrc
)

find_package(GSL REQUIRED)
target_link_libraries(MeasureView PRIVATE GSL::gsl GSL::gslcblas)

#set(OpenCV_ROOT "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
find_package(OpenCV REQUIRED)
target_link_libraries(MeasureView PUBLIC opencv_core opencv_imgproc opencv_highgui)

target_link_libraries(MeasureView PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_include_directories(MeasureView PUBLIC ${PROJECT_SOURCE_DIR}/..)

target_compile_definitions(MeasureView PRIVATE MEASUREVIEW_LIBRARY)

if(COMMAND qt_create_translation)
    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
    qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
